home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9233 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  132 lines

  1. Path: news.pi.net!news
  2. From: cat.tech@pi.net (Remy Cool)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: BTC++ 3.1 under W95 > Dialog as Main Window gives error
  5. Date: Thu, 29 Feb 1996 14:31:49 GMT
  6. Organization: Cool Applied Technology
  7. Message-ID: <4h4df8$1he@neptunus.pi.net>
  8. References: <4h1m97$9v0@neptunus.pi.net>
  9. Reply-To: cool@pi.net
  10. NNTP-Posting-Host: hen47.pi.net
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. cat.tech@pi.net (Remy Cool) wrote:
  14.  
  15.  
  16. >I use Borland Turbo C++ 3.1 for Windows (yes I know it's out of date)  under Windows 95.
  17.  
  18. >When I use a Dialog as my main window, an error -5 message pops up and the program terminates.
  19.  
  20. >Can this problem be solved ??? 
  21.  
  22. Well I found the solution myself, here it is :
  23.  
  24.  
  25. /* Cpp Source */
  26.  
  27. #include <owl.h>
  28. #include <dialog.h>
  29. .....
  30. ....
  31.  
  32. #define APPNAME "Application"
  33.  
  34. class TMyWindow : public TDialog
  35. {
  36.  
  37. public:
  38.         
  39.     TMyWindow();               
  40.            virtual ~TMyWindow();     
  41.     virtual LPSTR GetClassName();
  42.     virtual void GetWindowClass(WNDCLASS&);
  43. };
  44.  
  45.  
  46. TMyWindow::TMyWindow() : TDialog(NULL, APPNAME)
  47. { }
  48.  
  49. TMyWindow::~TMyWindow()
  50. { }
  51.  
  52. /* Supply new windows class name */
  53.  
  54. LPSTR TMyWindow::GetClassName()
  55. {
  56.     return APPNAME;
  57. }
  58.  
  59.  
  60. void TMyWindow::GetWindowClass(WNDCLASS & AWndClass)
  61. {
  62.     TDialog::GetWindowClass(AWndClass);
  63.     AWndClass.hIcon = LoadIcon(GetApplication()->hInstance, APPNAME);
  64. }
  65.  
  66.  
  67. class TMyApp : public TApplication
  68. {
  69.  
  70. public:
  71.         TMyApp(LPSTR AName, HINSTANCE hInstance, HINSTANCE hPrevInstance,
  72.              LPSTR lpCmd, int nCmdShow) :
  73.         TApplication(AName, hInstance, hPrevInstance, lpCmd, nCmdShow) {};
  74.  
  75.     virtual void InitMainWindow();
  76.             virtual void InitInstance();
  77. };
  78.  
  79.  
  80. void TMyApp::InitMainWindow()
  81. {
  82.     MainWindow = new TMyWindow();
  83. }
  84.  
  85. void TMyApp::InitInstance()
  86. {
  87.     TApplication::InitInstance();
  88. }
  89.  
  90. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  91.                    LPSTR lpCmd, int nCmdShow)
  92. {
  93.  
  94. TMyApp MyApp(APPNAME, hInstance, hPrevInstance, lpCmd, nCmdShow);
  95.  
  96. MyApp.Run();
  97.  
  98. return MyApp.Status;
  99.  
  100. }
  101.  
  102.  
  103.  
  104. /*  Resource  .RC  */
  105.  
  106. #include "windows.h"
  107. #include "owlrc.h"
  108.  
  109. Application ICON App.ico
  110.  
  111. Application DIALOG DISCARDABLE LOADONCALL PURE MOVEABLE 0, 0, 100, 112
  112. CLASS "Application"
  113. STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_GROUP
  114. CAPTION " Application : Dialog as Main Window"
  115. BEGIN
  116. END
  117.  
  118. -------------------------------------------------------------------------------------------------------------------------------------------------
  119.  
  120. This works, but is there a way to let the Dialog come up maximized ?
  121.  
  122. Also when I place a :
  123. Attr.Style | = WS_MAXIMIZE in a TWindow derived class constructor, the screen isn't maximized 
  124. when I run the App. Why ?
  125.  
  126. Regards,
  127.  
  128. Remy
  129.  
  130.  
  131.  
  132.